package com.gxa.educate.portal.tablet.earlyeducation.config;


import com.gxa.educate.portal.tablet.earlyeducation.interceptor.InteceptorHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author lh
 * @date 2022/7/7 13:53
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Autowired
    private InteceptorHandler inteceptorHandler;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //设置需要拦截的请求
        registry.addInterceptor(inteceptorHandler).addPathPatterns("/search/**", "/car/**", "/order/**", "/page");

    }

    @Override
    public void
    addResourceHandlers(ResourceHandlerRegistry registry) {
    //文件磁盘图片url 映射
    //配置server虚拟路径，handler为前台访问的目录，locations为files相对应的本地路径
   // registry.addResourceHandler(handler).addResourceLocations(location);
        registry.addResourceHandler("/img/**").addResourceLocations("https://lh-1312542810.cos.ap-chengdu.myqcloud.com");
    }
}
